package org.atlantis.ymer.command;

import org.atlantis.ymer.DisconnectReason;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.node.ObjectNode;

public class DisconnectCommand extends JsonCommand {

	public static final DisconnectCommand instance = new DisconnectCommand();

	private DisconnectReason reason;

	private DisconnectCommand() {
	}

	public DisconnectCommand(DisconnectReason reason) {
		this.reason = reason;
	}

	@Override
	public CommandType getType() {
		return CommandType.DISCONNECT;
	}

	@Override
	protected JsonNode toJson() {
		ObjectNode node = mapper.createObjectNode();
		node.put("type", CommandType.DISCONNECT.getValue());
		node.put("data", reason.getType().toString());
		return node;
	}
}
